#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int hIndex(vector<int>& citations)
    {
        sort(citations.begin(), citations.end());
        int i = 0;
        for (i = 0;i < citations.size();++i)
        {
            if (citations[i] >= citations.size() - i)
            {
                return citations.size() - i;
            }
        }
        return 0;
    }
};